'use strict';
var p = Object.defineProperty;
var m = (i, s, t) =>
  s in i
    ? p(i, s, { enumerable: !0, configurable: !0, writable: !0, value: t })
    : (i[s] = t);
var l = (i, s, t) => (m(i, typeof s != 'symbol' ? s + '' : s, t), t);
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
class g extends Error {
  constructor(t, e, a, o) {
    super();
    l(this, 'name');
    l(this, 'code');
    l(this, 'message');
    l(this, 'pos');
    l(this, 'linePos');
    (this.name = t), (this.code = a), (this.message = o), (this.pos = e);
  }
}
class M extends g {
  constructor(s, t, e) {
    super('YAMLParseError', s, t, e);
  }
}
class h extends g {
  constructor(s, t, e) {
    super('YAMLWarning', s, t, e);
  }
}
const f = (i, s) => t => {
  if (t.pos[0] === -1) return;
  t.linePos = t.pos.map(r => s.linePos(r));
  const { line: e, col: a } = t.linePos[0];
  t.message += ` at line ${e}, column ${a}`;
  let o = a - 1,
    n = i
      .substring(s.lineStarts[e - 1], s.lineStarts[e])
      .replace(/[\n\r]+$/, '');
  if (o >= 60 && n.length > 80) {
    const r = Math.min(o - 39, n.length - 79);
    (n = '…' + n.substring(r)), (o -= r - 1);
  }
  if (
    (n.length > 80 && (n = n.substring(0, 79) + '…'),
    e > 1 && /^ *$/.test(n.substring(0, o)))
  ) {
    let r = i.substring(s.lineStarts[e - 2], s.lineStarts[e - 1]);
    r.length > 80 &&
      (r =
        r.substring(0, 79) +
        `…
`),
      (n = r + n);
  }
  if (/[^ ]/.test(n)) {
    let r = 1;
    const c = t.linePos[1];
    c &&
      c.line === e &&
      c.col > a &&
      (r = Math.max(1, Math.min(c.col - a, 80 - o)));
    const u = ' '.repeat(o) + '^'.repeat(r);
    t.message += `:

${n}
${u}
`;
  }
};
exports.YAMLError = g;
exports.YAMLParseError = M;
exports.YAMLWarning = h;
exports.prettifyError = f;
